<template>
    <div class="NavHeader" :class="{'is_fixed': isScrool}">
        <div class="contanier">
            <div class="header-menu">
                <div class="item-menu">
                    <span class="title">首页</span>
                    <div class="children"><span>123</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">手机</span>
                    <div class="children"><span>345</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">服饰箱包</span>
                    <div class="children"><span>345</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">手机配件</span>
                    <div class="children"><span>345</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">抖音热销</span>
                    <div class="children"><span>345</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">家居生活</span>
                    <div class="children"><span>345</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">家用电器</span>
                    <div class="children"><span>345</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">美妆个护</span>
                    <div class="children"><span>345</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">TNT显示屏</span>
                    <div class="children"><span>345</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">抖音文创</span>
                    <div class="children"><span>345</span></div>
                </div>
                <div class="item-menu">
                    <span class="title">服务</span>
                    <div class="children"><span>345</span></div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'nav-header',
    data() {
        return {
            isScrool: false
        }
    },
    mounted() {
        window.addEventListener('scroll', this.scroolTop);
    },
    destroyed() {
        window.removeEventListener('scroll', this.scroolTop, false);
    },
    methods: {
        scroolTop() {
            let scroolHeight = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
            this.isScrool = scroolHeight > 130 ? true: false;
        }
    }
}
</script>

<style lang="less">
.NavHeader {
    height: 80px;
    background-color: #fff;
    box-shadow: 0px 7px 6px 0px rgba(0,0,0,0.11);
    z-index: 100;
    &.is_fixed {
        position: fixed;
        top: 0px;
        width: 100%;
        box-shadow: 0px 7px 6px 0px rgba(0,0,0,0.11);
    }
    .contanier {
        .header-menu {
            display: flex;
            height: 80px;
            line-height: 80px;
            position: relative;
            .item-menu {
                .title {
                    cursor: pointer;
                    margin-right: 40px;
                    font-size: 14px;
                }
                .children {
                    opacity: 0;
                    height: 0px;
                    width: 1226px;
                    position: absolute;
                    top: 80px;
                    left: 0px;
                    border: 1px solid pink;
                    transition: all .5s;
                    z-index: 20;
                    overflow: hidden;
                    background-color: #fff;
                }
                &:hover {
                    color: rgb(127,127,127);
                    font-weight: 700;
                    .children {
                        height: 200px;
                        opacity: 1;
                    }
                }
            }
        }
        .center-menu {
            height: 800px;
        }
    }
}
</style>
